﻿using PetaPoco;
using System;
using System.ComponentModel.DataAnnotations;

namespace Cxuu.Models
{
    [TableName("cxuu_admin_user")]
    [PrimaryKey("Id", AutoIncrement = true)]
    public class AdminUser
    {
        public int Id { get; set; }
        [Display(Name = "用户组")]
        public int Gid { get; set; }

        [Display(Name = "用户名")]
        [Required(ErrorMessage = "请填写用户名")]
        public string Username { get; set; }
        [Display(Name = "密码 ")]
        public string Password { get; set; }
        [Display(Name = "昵称")]
        [Required(ErrorMessage = "请填写昵称")]
        public string Nickname { get; set; }
        public DateTime Logintime { get; set; }
        public string Loginip { get; set; }
        [Display(Name = "状态")]
        public bool Status { get; set; } = true;

    }

    public class EditAdminUser
    {
        public int Id { get; set; }
        [Display(Name = "用户组")]
        public int Gid { get; set; }
        [Display(Name = "用户名")]
        [Required(ErrorMessage = "请输入{0}")]
        public string Username { get; set; }
        [Display(Name = "密码")]
        public string Password { get; set; }
        [Display(Name = "昵称")]
        [RegularExpression(RegxPatterns.Chs, ErrorMessage = "{0}必须为中文")]
        [StringLength(16, MinimumLength = 2, ErrorMessage = "{0}至少{2}位,并且不能超过{1}位")]
        [Required(ErrorMessage = "请输入{0}")]
        public string Nickname { get; set; }
        [Display(Name = "用户状态")]
        [Required(ErrorMessage = "请选择用户状态")]
        public bool Status { get; set; } = true;

        public DateTime Logintime { get; set; }
        public string Loginip { get; set; }

    }

    public class EditPassWord
    {
        [Display(Name = "登录名")]
        public string Username { get; set; }


        [Display(Name = "新密码")]
        [Required(ErrorMessage = "请输入{0}")]
        [RegularExpression(RegxPatterns.Pass, ErrorMessage = "新密码为字母数字下划线及特殊字符组合,且最少6位最多20位！")]
        public string Password { get; set; }

        [Display(Name = "旧密码")]
        [Required(ErrorMessage = "请输入{0}")]

        public string OldPassword { get; set; }

        [Display(Name = "昵称")]
        [RegularExpression(RegxPatterns.Chs, ErrorMessage = "{0}必须为中文")]
        [StringLength(16, MinimumLength = 2, ErrorMessage = "{0}至少{2}位,并且不能超过{1}位")]
        [Required(ErrorMessage = "请输入{0}")]

        public string Nickname { get; set; }

    }


    public class ViewAdminUser
    {
        public int Id { get; set; }
        [Display(Name = "用户组")]
        public int Gid { get; set; }

        [Display(Name = "用户组")]
        public string Groupname { get; set; }

        [Display(Name = "用户名")]
        public string Username { get; set; }

        [Display(Name = "昵称")]

        public string Nickname { get; set; }
        [Display(Name = "用户状态")]

        public bool Status { get; set; } = true;


        public DateTime Logintime { get; set; }
        public string Loginip { get; set; }

    }


    public class UserIdAndName
    {
        public int Id { get; set; }
        public string Username { get; set; }
        public bool Status { get; set; }

    }
}
